<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
<title>{$title}</title>
<link rel="stylesheet" type="text/css" href="Res/index/css/Iframe.css" />
<link rel="stylesheet" href="Res/index/utilLib/bootstrap.min.css" type="text/css" media="screen" />
<script type="text/javascript" src="Res/js/jquery-1.8.3.min.js"></script>
</head>

<body>
<span class="cp_title">权限管理－编辑</span>
<div class="add_cp">
	<a href="index.php?c=action&m=view">返回权限管理列表</a>
</div>
<div class="table_con" style="margin: 0 auto;text-align: center;">
    <form class="form-horizontal" role="form" action="index.php?c=action&m=new_edit" method="post">
    <div class="form-group">
        <label for="user_name" class="col-sm-2 control-label">父ID：</label>
        <div class="col-sm-5">
            <select id="parent_id" name="parent_id" class="form-control">
                <option value="-1">請選擇</option>
                <option value="0">父菜單(0)</option>
                {foreach from=$struct item=row}
                {if $edit.parent_id == $row.action_id}
                    <option value="{$row.action_id}" selected="true">{$row.action_chinese}({$row.action_id})</option>                  
                {else}
                    <option value="{$row.action_id}">{$row.action_chinese}({$row.action_id})</option>
                {/if}
                    {foreach from=$row.child item=child}
                    {if $edit.parent_id == $child.action_id}
                    <option value="{$child.action_id}" selected="true">----------{$child.action_chinese}({$child.action_id})</option>                                     
                    {else}
                    <option value="{$child.action_id}">----------{$child.action_chinese}({$child.action_id})</option>
                    {/if}
                    {/foreach}
                {/foreach}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label for="user_pass" class="col-sm-2 control-label">中文名称：</label>
        <div class="col-sm-5">
            <input type="text" autocomplete="off" value="{$edit.action_chinese}" class="form-control" id="action_chinese" name="action_chinese" placeholder="中文名称" />
        </div>
    </div>
    
    <div class="form-group">
        <label for="user_pass" class="col-sm-2 control-label">操作url：</label>        
        <div class="col-sm-2">
            <label for="class_id">Class</label><input type="text" id="class_id" name="class_id" autocomplete="off" value="{$class_id}" class="form-control" placeholder="类名" />            
        </div>
        <div class="col-sm-2">
            <label for="method_id">Method</label><input type="text" id="method_id" name="method_id" value="{$method_id}" class="form-control" placeholder="方法名" />            
        </div>        
    </div>
    <div class="form-group">
        <label for="user_pass" class="col-sm-2 control-label">权限代码：</label>
        <div class="col-sm-5">
            <input type="text" readonly="true" autocomplete="off" value="{$edit.action_code}" class="form-control" id="action_code" name="action_code" placeholder="权限代码" />
        </div>
    </div>
    <div class="form-group">
        <label for="user_pass" class="col-sm-2 control-label">预览完整的URL：</label>
        <div class="col-sm-5">
            <input type="text" readonly="true" autocomplete="off" value="{$edit.action_url}" class="form-control" id="action_url" name="action_url" placeholder="预览完整的URL" />
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">关联URL：</label>        
        <div class="col-sm-2">
            <label for="class_id">Class</label><input type="text" id="rel_class_id" name="rel_class_id" autocomplete="off" 
                                                      value="{$rel_class_id}" class="form-control" placeholder="类名" />            
        </div>
        <div class="col-sm-2">
            <label for="method_id">Method</label><input type="text" id="rel_method_id" name="rel_method_id" 
                                                        value="{$rel_method_id}" class="form-control" placeholder="方法名" />            
        </div>        
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">关联权限代码：</label>
        <div class="col-sm-5">
            <input type="text" readonly="true" autocomplete="off" value="{$edit.rel_action_code}" class="form-control" 
                   id="rel_action_code" name="rel_action_code" placeholder="关联权限代码" />
        </div>
    </div>
    
    <div class="form-group">
        <label class="col-sm-2 control-label">是否作菜单：</label>
        <div class="col-sm-5">
            <div class="checkbox">
                <label>
                  <input type="checkbox" id="checkboxSuccess" value="1" name="is_menu" />
                  是作为菜单
                </label>
              </div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-5">
            <input type="hidden" value="{$token}" name="token" />
            <input type="hidden" value="{$edit.action_id}" name="action_id" />
            <button type="submit" class="btn btn-primary btn-lg btn-block">编辑</button>            
        </div>
    </div>
    </form>
</div>
{literal}
<script>    
$(function(){
    var url_arr = new Array();
    url_arr['c'] = '';
    url_arr['m'] = '';
    url_arr['rel_c'] = '';
    url_arr['rel_m'] = ''; 
    $("#class_id").keyup(function(){  
        mc();
    }).focus(function(){
        mc();
    });
    $("#method_id").keyup(function(){        
        mc();

    }).focus(function(){
        mc();
    });
    $("#rel_class_id").keyup(function(){
        rel_mc();
    }).focus(function(){
        rel_mc();
    });
    $("#rel_method_id").keyup(function(){
        rel_mc();
    }).focus(function(){
        rel_mc();
    });
    function rel_mc(){
        var c = $.trim($("#rel_class_id").val());
        var m = $.trim($("#rel_method_id").val());        
        if(m !== '' || c !== '') {
            url_arr['rel_c'] = c;
            url_arr['rel_m'] = m;        
            $("#rel_action_code").val(url_arr['rel_c'] + ':' + url_arr['rel_m']);
        } else {
            $("#rel_class_id").val('');
            $("#rel_method_id").val('');
        }
    }
    function mc(){
        var m = $.trim($("#method_id").val());
        var c = $.trim($("#class_id").val());
        if(m !== '' || c !== '') {
            url_arr['c'] = c;
            url_arr['m'] = m;        
            var url = 'c=' + url_arr['c'] + '&m=' + url_arr['m'];
            $("#action_url").val(url);
            $("#action_code").val(url_arr['c'] + ':' + url_arr['m']);
        } else {
            $("#action_url").val('');
            $("#action_code").val('');
        }
    }
});
</script>
{/literal}
</script>
</body>
</html>

